<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <script src="script.js">
      a = ['a','a','a','b','b','c','c','c','c','d','d','d','d'] 

var res = {
  'a':0,
  'b':0,
  'c':0,
  'd':0
};

for (var i = 0; i < a.length; i++)
{
    if (a[i] == 'a')
      res.a += 1;
    else if (a[i] == 'b')
      res.b += 1;
    else if (a[i] == 'c')
      res.c += 1;
    else
      res.d += 1;

}
console.log(res);
    </script>
  </body>
</html>